訊息佈達產品項目技術文件認識銓尹友站連結業務擴展雲端欄目雲端展示聯絡我們
  • 聯絡我們
  1. 首頁
  2. 技術文件
  3. 電腦硬體維修
  4. 利用 iperf 測試網路效能

利用 iperf 測試網路效能

轉貼自: https://cms.35g.tw/coding/%E5%88%A9%E7%94%A8-iperf-%E6%B8%AC%E8%A9%A6%E7%B6%B2%E8%B7%AF%E6%95%88%E8%83%BD/

利用 iperf 測試網路效能

測試網路速度是否為理想狀況時,一般利網路芳鄰、FTP傳軟來達成測試的目地,但如果需要重覆測試時,這樣的測法可能比較沒有效率了,所以iperf這樣的工具對於測試網路傳輸的速度來說就較方便。iPerf3已釋出,此篇文章前半段維持iPerf2內容,增加後半段補充iPerf3的測試紀錄,iPerf2/3這兩個版本並不相容,但都能測試出網路效能,依照你的軟體環境及測試環境選擇版本,客戶端與伺服端的版本必需要相同

 

下載安裝

官網中有各種版本提供使用,選擇好你要使用的環境下載並解壓就能使用。

示範中使用Windows環境測試,所以下載Iperf 2.0.5-2,接下來就開始看下去該怎麼使用。

iperf命令說明

 Usage: iperf [-s|-c host] [options] iperf [-h|--help] [-v|--version] Client/Server: -f, --format [kmKM] format to report: Kbits, Mbits, KBytes, MBytes -i, --interval # seconds between periodic bandwidth reports -l, --len #[KM] length of buffer to read or write (default 8 KB) -m, --print_mss print TCP maximum segment size (MTU - TCP/IP header) -o, --output  output the report or error message to this specified file -p, --port # server port to listen on/connect to -u, --udp use UDP rather than TCP -w, --window #[KM] TCP window size (socket buffer size) -B, --bind  bind to , an interface or multicast address -C, --compatibility for use with older versions does not sent extra msgs -M, --mss # set TCP maximum segment size (MTU - 40 bytes) -N, --nodelay set TCP no delay, disabling Nagle's Algorithm -V, --IPv6Version Set the domain to IPv6 Server specific: -s, --server run in server mode -U, --single_udp run in single threaded UDP mode -D, --daemon run the server as a daemon Client specific: -b, --bandwidth #[KM] for UDP, bandwidth to send at in bits/sec (default 1 Mbit/sec, implies -u) -c, --client  run in client mode, connecting to  -d, --dualtest Do a bidirectional test simultaneously -n, --num #[KM] number of bytes to transmit (instead of -t) -r, --tradeoff Do a bidirectional test individually -t, --time # time in seconds to transmit for (default 10 secs) -F, --fileinput  input the data to be transmitted from a file -I, --stdin input the data to be transmitted from stdin -L, --listenport # port to receive bidirectional tests back on -P, --parallel # number of parallel client threads to run -T, --ttl # time-to-live, for multicast (default 1) -Z, --linux-congestion  set TCP congestion control algorithm (Linux only) Miscellaneous: -x, --reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports -y, --reportstyle C report as a Comma-Separated Values -h, --help print this message and quit -v, --version print version information and quit [KM] Indicates options that support a K or M suffix for kilo- or mega- The TCP window size option can be set by the environment variable TCP_WINDOW_SIZE. Most other options can be set by an environment variable IPERF_, such as IPERF_BANDWIDTH. 

將上面的整理一下,將Server、Client共通歸類一起做說明,其他的再分開解釋。

 參數說明 -s 啟動server模式,例如:iperf -s -c 啟動client模式,命令後接server的位址,例如:iperf -c 192.168.1.3 通用參數 -f [k|m|K|M] 報告結果顯示的單位,以Kbits, Mbits, KBytes, MBytes,例如:iperf -c 192.168.1.3 -f K -i sec 報告顯示的時間間隔(以秒為單位),例如:iperf -c 192.168.1.3 -i 2 -l [KM] 緩衝區大小,預設是8KB,例如:iperf -c 192.168.1.3 -l 16 -m 顯示MTU最大值 -o 將報告與錯誤信息輸出到檔案,例如:iperf -c 192.168.1.3 -o c:\iperf-log.txt -p server使用的連接埠或client使用的連接埠,兩端連接埠要一致,例如:iperf -s -p 9999 -u 使用udp通訊規格 -w 指定TCP框架大小,預設是8KB -B 綁定一個主機地址,可以是介面或是廣播位址,當主機端同時有很多位址時才需要綁定 -C 相容舊版本(兩端版本不致時使用) -M 設定TCP封包的最大MTU值 -N 設定TCP不延時 -V 傳輸ipv6資料封包 server專用 -D 背景服務方式運行,例如:iperf -s -D -U 使用單一執行緒使用UDp模式 client專用 -b UDP測試專用,可以設定每秒傳送的速度 -d 同時進行雙向傳輸測試 -n 指定傳輸的大小,例如: iperf -c 192.168.1.3 -n 100000 -r 單獨進行雙向傳輸測試 -t 測試時間長度,預設10秒,例如: iperf -c 192.168.1.3 -t 5 -F 使用指定檔案來傳輸 -I 使用stdin方式當做傳輸內容 -T 指定ttl值 

開始測試

使用iperf需要要有2台電腦,一台為serve端,另一台為client端,測試環境使用windows環境與Giga網路來當做示範,分為Server與Client。

Server(伺服端):

Server端的命令預設非常的簡單,只要執行

 iperf –s 

如下圖就開始運作。

Client(客戶端):

Client端設定比較多,主要是看你要選擇怎麼樣的測試方式,示範中使用下面的命令:

 iperf –c 192.168.3.58 –w 100M –t 120 –i 10 

解釋一下:

 -c 192.168.3.58 :Server端的IP -w 100M :測試的檔案大小 -t 120:監視測量數據時間為120秒 -i 10:每隔10秒將數據顯示出來 

測試結果

依照所執行的命令需要測約120秒左右時間,看到下圖結果報告顯示總共測試從0.0~121.3秒,傳輸9.28GByte,

平均速度(Bandwidth)約在657Mbits/sec之間,對於Giga環境已經發揮6成的速度,這在Giga環境下測試的值並不是理想值,測試時必需要關閉一些網路軟體或是內建的QoS機制才有可能發揮到極速,所以速度並沒有我第一次在測試時平均可以跑到800Mbits/sec。

iPerf3

iPerf約莫許久後終於發行3.0版本,通稱為iPerf3,其舊的2.0版本稱iPerf2,如你要使用iPerf3新版本測試網路效能時,客戶端與伺服器端版本必需要都是iPerf3才能完成測試,這點官網有提到iPerf3 is not backwards compatible with iPerf2.,其他參數可以依照前半段文章不需要做變更就能繼續測試。

下載iPerf3

iPerf目前支援更多平台,前往官網下載頁面下載,後面測試的版本使用iPerf 3.1.3

iPerf3 開始測試

下面舉出使用iPerf3進行客戶端與伺服器配測試的紀錄檔供參考。

客戶端

客戶端使用Windows,而伺服器端使用Arch Linux

  

伺服器端

因剛好沒有2台Windows供測試,伺服器端使用Arch Linux

  

結語

從舊文章測試擷圖與新文章測試結果也能看到效能上的差異,其中舊文章使用的是介面卡的網路卡,而新增加的是使用內建的網路卡,使用的Switch Hub是一樣的,效能上面能看到一些差距。

© 2017 銓尹行銷顧問有限公司   Tel : 06-2881890   Fax : 06-2881810   E-mail : service小老鼠符號pctop.com.tw
Address : 71751 台南市仁德區成功一街153號   Support of technicality : 原點網頁設計公司   Victors : 01541435